#include <iostream>
#include <string>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>

void * threadHandler(void * arg)
{
    std::string name  = (const char*) arg;
    while (true)
    {
        /* code */
        std::cout<<"我是新线程，pid："<<getpid()<<"，线程名："<<name<<std::endl;
        sleep(1);
    }
    return nullptr;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadHandler,(void*)"thread-1");
    while (true)
    {
        /* code */
        
        std::cout<<"我是主线程，pid："<<getpid()<<std::endl;
        sleep(1);
    }
    
    return 0;
}